/* Print is contains the functions that print the different elements of the program.  These include the header, formatting, token, and the read source */

#include <iostream>
#include <time.h>
#include "Print.h"

const string symbolStrings[] = 
{
    "<no token>", "<IDENTIFIER>", "<NUMBER>", "<STRING>",
    "^","*","(",")","-","+","=","[","]",":",";",
    "<",">",",",".","/",":=","<=",">=","<>","..",
    "<END OF FILE>", "<ERROR>",
    "AND","ARRAY","BEGIN","CASE","CONST","DIV","DO","DOWNTO",
    "ELSE","END","FILE","FOR","FUNCTION","GOTO","IF","IN",
    "LABEL","MOD","NIL","NOT","OF","OR","PACKED","PROCEDURE",
    "PROGRAM","RECORD","REPEAT","SET","THEN","TO","TYPE","UNTIL",
    "VAR","WHILE","WITH",
};

// Public Functions

//Print constructor, takes no parameters
Print::Print() {}

//PrintLine takes sourceLine as the parameter and then prints the line count as well as the sourceLine, it increments the lineCount
void Print::PrintLine(const string & sourceLine) 
{
	cout << lineCount << ": " << sourceLine << "\n";
	lineCount++;
}

//PrintToken takes token as parameter and prints it in the correct format
void Print::PrintToken(Tokenizer & token) {
	//cout << ">> " << token.FetchTokenCode() << "\t" << token.FetchTokenString() << "\n";
}

//Print deconstructor
Print::~Print() {
}

// Private Functions

int pageNumber = 1;
string fName;
//string date; removed because of C code used
int lineCount = 1;

//PrintPageHeader takes pageNumber and fName as parameters and then prints the header of the page in proper format
void Print::PrintPageHeader(int pageNumber, string fName)
{
	time_t t = time (0);
	struct tm * now = localtime( & t);
	//printf("Page\t%d\t%s\t%s\n", pageNumber, fName, asctime(localtime(&now)));
	cout << "Page " << pageNumber << "\t" << fName << "\t" << asctime(now) << endl;
	pageNumber++;
	lineCount = 1;
}

